﻿@using Abp.Application.Services.Dto
@using Mes5GService
@using Abp.Timing;
@using Mes5GService.Web.Areas.AppAreaName.Models.Settings
@using Mes5GService.Web.Areas.AppAreaName.Startup
@model SettingsViewModel
@{
    ViewBag.CurrentPageName = AppAreaNamePageNames.Tenant.Settings;
}

@section Styles
{
    <link rel="stylesheet" abp-href="/view-resources/Areas/AppAreaName/Views/Common/_KeyValueListManager.css" asp-append-version="true"/>
}

@section Scripts
{
    <script>
    var isOpenIdEnabled = @(Model.EnabledSocialLoginSettings.Contains("OpenId") ? "true" : "false");
    var openIdConnectClaimsMappings = @Html.Raw(Model.Settings.ExternalLoginProviderSettings.OpenIdConnectClaimsMapping == null || Model.Settings.ExternalLoginProviderSettings.OpenIdConnectClaimsMapping.Count == 0 ? "[]" : Newtonsoft.Json.JsonConvert.SerializeObject(Model.Settings.ExternalLoginProviderSettings.OpenIdConnectClaimsMapping));

    var isWsFederationEnabled = @(Model.EnabledSocialLoginSettings.Contains("WsFederation") ? "true" : "false");
    var wsFederationClaimsMappings = @Html.Raw(Model.Settings.ExternalLoginProviderSettings.WsFederationClaimsMapping == null || Model.Settings.ExternalLoginProviderSettings.WsFederationClaimsMapping.Count == 0 ? "[]" : Newtonsoft.Json.JsonConvert.SerializeObject(Model.Settings.ExternalLoginProviderSettings.WsFederationClaimsMapping));

    </script>
    <script abp-src="/view-resources/Areas/AppAreaName/Views/Common/_KeyValueListManager.js" asp-append-version="true"></script>
    <script abp-src="/view-resources/Areas/AppAreaName/Views/Settings/Index.js" asp-append-version="true"></script>
}

<div class="content d-flex flex-column flex-column-fluid" id="kt_content">
<abp-page-subheader title="@L("Settings")" description="@L("SettingsHeaderInfo")">
    <button id="SaveAllSettingsButton" class="btn btn-primary">
        <i class="fa fa-save"></i> @L("SaveAll")
    </button>
</abp-page-subheader>

<div class="@(await GetContainerClass())">
<div class="card card-custom gutter-b">
<div class="card-body">
<div id="SettingsTabPanel" class="tabbable-line">
<ul class="nav nav-tabs" role="tablist">
    @if (Clock.SupportsMultipleTimezone)
    {
        <li class="nav-item">
            <a href="#SettingsGeneralTab" aria-expanded="true" class="nav-link active" data-toggle="tab" role="tab">
                @L("General")
            </a>
        </li>
    }

    <li class="nav-item">
        <a href="#SettingsAppearanceTab" aria-expanded="false" class="nav-link @((!Clock.SupportsMultipleTimezone) ? "active" : "")" data-toggle="tab" role="tab">
            @L("Appearance")
        </a>
    </li>

    <li class="nav-item">
        <a href="#SettingsUserManagementTab" aria-expanded="true" class="nav-link" data-toggle="tab" role="tab">
            @L("UserManagement")
        </a>
    </li>

    <li class="nav-item">
        <a href="#SecurityManagementTab" aria-expanded="true" class="nav-link" data-toggle="tab" role="tab">
            @L("Security")
        </a>
    </li>

    @if (!ViewBag.IsMultiTenancyEnabled || AbpZeroTemplateConsts.AllowTenantsToChangeEmailSettings)
    {
        <li class="nav-item">
            <a href="#SettingsEmailSmtpTab" aria-expanded="true" class="nav-link" data-toggle="tab" role="tab">
                @L("EmailSmtp")
            </a>
        </li>
    }

    @if (ViewBag.IsMultiTenancyEnabled)
    {
        <li class="nav-item">
            <a href="#BillingTab" aria-expanded="true" class="nav-link" data-toggle="tab" role="tab">
                @L("Invoice")
            </a>
        </li>
    }

    @if (!ViewBag.IsMultiTenancyEnabled)
    {
        <li class="nav-item">
            <a href="#OtherSettingsTab" aria-expanded="true" class="nav-link" data-toggle="tab" role="tab">
                @L("OtherSettings")
            </a>
        </li>
    }

    @if (Model.EnabledSocialLoginSettings.Any())
    {
        <li class="nav-item">
            <a href="#ExternalLoginSettingsTab" aria-expanded="true" class="nav-link" data-toggle="tab" role="tab">
                @L("ExternalLoginSettings")
            </a>
        </li>
    }
</ul>

<div class="tab-content p-5">

@if (Clock.SupportsMultipleTimezone)
{
    <div class="tab-pane active" id="SettingsGeneralTab">
        <form id="GeneralSettingsForm">
            <div class="form-group">
                <label for="Timezone">@L("Timezone")</label>
                @Html.DropDownList("Timezone", Model.TimezoneItems.Select(i => i.ToSelectListItem()), new {@class = "form-control", id = "Timezone"})
            </div>
            <div>
                @Html.Hidden("TimezoneForComparison", Model.Settings.General.TimezoneForComparison)
            </div>
        </form>
    </div>
}

<div class="tab-pane @((!Clock.SupportsMultipleTimezone) ? "active" : "")" id="SettingsAppearanceTab">
    <div class="row">
        <div class="col-sm-6">
            <form id="SettingsLogoUploadForm" method="POST" action="@Url.Action("UploadLogo", "TenantCustomization", new {area = string.Empty})">
                <h5>@L("ApplicationLogo")</h5>
                @if (ViewBag.TenantLogoId != null)
                {
                    <div class="form-group" style="background: url(/Common/Images/transparent_background.png); width: 50%; padding: 5px;">
                        <a href="@Url.Action("GetLogo", "TenantCustomization", new {area = string.Empty, tenantId = ViewBag.TenantId})" target="_blank">
                            <img height="38" src="@Url.Action("GetLogo", "TenantCustomization", new {area = string.Empty, tenantId = ViewBag.TenantId})">
                        </a>
                    </div>
                }
                <div class="form-group">
                    <input type="file" name="ApplicationLogoImage" class="col-lg-12"/>
                    <span class="form-text text-muted col-lg-12">@L("UploadLogo_Info")</span>
                </div>
                <button class="btn btn-primary" type="submit">@L("Upload")</button>
                <button class="btn btn-default" type="reset">@L("Clear")</button>
            </form>
        </div>
        <div class="col-sm-6">
            <form id="SettingsCustomCssUploadForm" method="POST" action="@Url.Action("UploadCustomCss", "TenantCustomization", new {area = string.Empty})">
                <h5>@L("CustomCSS")</h5>
                @if (ViewBag.TenantCustomCssId != null)
                {
                    <p>
                        <a href="@Url.Action("GetCustomCss", "TenantCustomization", new {area = string.Empty, tenantId = ViewBag.TenantId})" target="_blank">@L("Download")</a>
                    </p>
                }
                <div class="form-group">
                    <input type="file" name="CustomCssFile" class="col-lg-12"/>
                    <span class="form-text text-muted col-lg-12">@L("UploadCSS_Info")</span>
                </div>
                <button class="btn btn-primary" type="submit">@L("Upload")</button>
                <button class="btn btn-default" type="reset">@L("Clear")</button>
            </form>
        </div>
    </div>
</div>

<div class="tab-pane" id="SettingsUserManagementTab">

    <form id="FormBasedRegistrationSettingsForm" class="form">
        <h5>@L("FormBasedRegistration")</h5>
        <div class="checkbox-list">
            <div class="form-group">
                <label for="Setting_AllowSelfRegistration" class="checkbox checkbox-outline col-lg-12">
                    <input id="Setting_AllowSelfRegistration" type="checkbox" name="AllowSelfRegistration" value="true" @(Model.Settings.UserManagement.AllowSelfRegistration ? "checked=\"checked\"" : "")>
                    @L("AllowUsersToRegisterThemselves")
                    <span></span>
                </label>
                <span class="form-text text-muted">@L("AllowUsersToRıegisterThemselves_Hint")</span>
            </div>
            <div id="Setting_AllowSelfRegistration_Content">
                <div class="form-group">
                    <label for="Setting_IsNewRegisteredUserActiveByDefault" class="checkbox checkbox-outline col-lg-12">
                        <input id="Setting_IsNewRegisteredUserActiveByDefault" type="checkbox" name="IsNewRegisteredUserActiveByDefault" value="true" @(Model.Settings.UserManagement.IsNewRegisteredUserActiveByDefault ? "checked=\"checked\"" : "")>
                        @L("NewRegisteredUsersIsActiveByDefault")
                        <span></span>
                    </label>
                    <span class="form-text text-muted">@L("NewRegisteredUsersIsActiveByDefault_Hint")</span>
                </div>
                <div class="form-group">
                    <label for="Setting_UseCaptchaOnRegistration" class="checkbox checkbox-outline">
                        <input id="Setting_UseCaptchaOnRegistration" type="checkbox" name="UseCaptchaOnRegistration" value="true" @(Model.Settings.UserManagement.UseCaptchaOnRegistration ? "checked=\"checked\"" : "")>
                        @L("UseCaptchaOnRegistration")
                        <span></span>
                    </label>
                </div>
                <div class="form-group">
                    <label for="Setting_UseCaptchaOnLogin" class="checkbox checkbox-outline">
                        <input id="Setting_UseCaptchaOnLogin" type="checkbox" name="UseCaptchaOnLogin" value="true" @(Model.Settings.UserManagement.UseCaptchaOnLogin ? "checked=\"checked\"" : "")>
                        @L("UseCaptchaOnLogin")
                        <span></span>
                    </label>
                </div>
            </div>
            <h5>@L("SessionTimeOut")</h5>
            <label for="Setting_IsSessionTimeOutEnabled" class="checkbox checkbox-outline">
                <input id="Setting_IsSessionTimeOutEnabled" type="checkbox" name="IsEnabled" value="true" @(Model.Settings.UserManagement.SessionTimeOutSettings.IsEnabled ? "checked=\"checked\"" : "")>
                @L("IsSessionTimeOutEnabled")
                <span></span>
            </label>
            <div class="divSessionTimeOut">
                <label for="Setting_ShowLockScreenWhenTimedOut" class="checkbox checkbox-outline">
                    <input id="Setting_ShowLockScreenWhenTimedOut" type="checkbox" name="ShowLockScreenWhenTimedOut" value="true" @(Model.Settings.UserManagement.SessionTimeOutSettings.ShowLockScreenWhenTimedOut ? "checked=\"checked\"" : "")>
                    @L("ShowLockScreenWhenTimedOut")
                    <span></span>
                </label>
                <div class="form-group">
                    <label for="Setting_SessionTimeOutSecond">@L("SessionTimeOutSecond")</label>
                    <input id="Setting_SessionTimeOutSecond" type="number" name="TimeOutSecond" class="form-control edited" min="10" value="@Model.Settings.UserManagement.SessionTimeOutSettings.TimeOutSecond">
                </div>
                <div class="form-group">
                    <label for="Setting_ShowTimeOutNotificationSecond">@L("ShowTimeOutNotificationSecond")</label>
                    <input id="Setting_ShowTimeOutNotificationSecond" type="number" name="ShowTimeOutNotificationSecond" class="form-control edited" min="10" value="@Model.Settings.UserManagement.SessionTimeOutSettings.ShowTimeOutNotificationSecond">
                </div>
            </div>
        </div>
    </form>

    @if (Model.Settings.Ldap.IsModuleEnabled)
    {
        <form id="LdapSettingsForm">
            <h5 class="margin-top-20">@L("LdapSettings")</h5>
            <label for="Setting_LdapIsEnabled" class="checkbox checkbox-outline">
                <input id="Setting_LdapIsEnabled" type="checkbox" name="IsEnabled" value="true" @(Model.Settings.Ldap.IsEnabled ? "checked=\"checked\"" : "")>
                @L("EnableLdapAuthentication")
                <span></span>
            </label>
            <div class="form-group">
                <label for="Domain">@L("DomainName")</label>
                <input id="Domain" type="text" name="Domain" class="form-control" value="@Model.Settings.Ldap.Domain" maxlength="128">
            </div>
            <div class="form-group">
                <label for="UserName">@L("UserName")</label>
                <input id="UserName" type="text" name="UserName" class="form-control" value="@Model.Settings.Ldap.UserName" maxlength="128">
            </div>
            <div class="form-group">
                <label for="Password">@L("Password")</label>
                <input id="Password" type="password" name="Password" class="form-control" value="@Model.Settings.Ldap.Password" maxlength="128" autocomplete="new-password">
            </div>
        </form>
    }

    <form id="UserManagementOtherSettingsForm">
        <h5 class="mt-5">@L("OtherSettings")</h5>
        <label for="Settings_IsEmailConfirmationRequiredForLogin" class="checkbox checkbox-outline">
            <input id="Settings_IsEmailConfirmationRequiredForLogin" type="checkbox" name="IsEmailConfirmationRequiredForLogin" value="true" @(Model.Settings.UserManagement.IsEmailConfirmationRequiredForLogin ? "checked=\"checked\"" : "")>
            @L("EmailConfirmationRequiredForLogin")
            <span></span>
        </label>
        <h5 class="mt-5">@L("CookieConsent")</h5>
        <label for="Setting_IsCookieConsentEnabled" class="checkbox checkbox-outline">
            <input id="Setting_IsCookieConsentEnabled" type="checkbox" name="IsCookieConsentEnabled" value="true" @(Model.Settings.UserManagement.IsCookieConsentEnabled ? "checked=\"checked\"" : "")>
            @L("IsCookieConsentEnabled")
            <span></span>
        </label>
        <h5 class="mt-5">@L("Profile")</h5>
        <label for="Setting_AllowUsingGravatarProfilePicture" class="checkbox checkbox-outline">
            <input id="Setting_AllowUsingGravatarProfilePicture" type="checkbox" name="AllowUsingGravatarProfilePicture" value="true" @(Model.Settings.UserManagement.AllowUsingGravatarProfilePicture ? "checked=\"checked\"" : "")>
            @L("AllowUsingGravatarProfilePicture")
            <span></span>
        </label>
    </form>
</div>

<div id="SecurityManagementTab" class="tab-pane">
    <div>
        <h5>@L("PasswordComplexity")</h5>
        <label for="Setting_PasswordComplexity_UseDefaultSettings" class="checkbox checkbox-outline">
            <input id="Setting_PasswordComplexity_UseDefaultSettings" type="checkbox" name="UseDefaultSettings" value="true" @(Model.Settings.Security.UseDefaultPasswordComplexitySettings ? "checked=\"checked\"" : "")>
            @L("UseDefaultSettings")
            <span></span>
        </label>
        <form class="p-5" id="PasswordComplexitySettingsForm" style="@(Model.Settings.Security.UseDefaultPasswordComplexitySettings ? "display:none;" : "")">
            <div class="checkbox-list">
                <label for="Setting_PasswordComplexity_RequireDigit" class="checkbox checkbox-outline">
                    <input id="Setting_PasswordComplexity_RequireDigit" type="checkbox" name="RequireDigit" value="true" @(Model.Settings.Security.PasswordComplexity.RequireDigit ? "checked=\"checked\"" : "")>
                    @L("PasswordComplexity_RequireDigit")
                    <span></span>
                </label>
                <label for="Setting_PasswordComplexity_RequireLowercase" class="checkbox checkbox-outline">
                    <input id="Setting_PasswordComplexity_RequireLowercase" type="checkbox" name="RequireLowercase" value="true" @(Model.Settings.Security.PasswordComplexity.RequireLowercase ? "checked=\"checked\"" : "")>
                    @L("PasswordComplexity_RequireLowercase")
                    <span></span>
                </label>
                <label for="Setting_PasswordComplexity_RequireNonAlphanumeric" class="checkbox checkbox-outline">
                    <input id="Setting_PasswordComplexity_RequireNonAlphanumeric" type="checkbox" name="RequireNonAlphanumeric" value="true" @(Model.Settings.Security.PasswordComplexity.RequireNonAlphanumeric ? "checked=\"checked\"" : "")>
                    @L("PasswordComplexity_RequireNonAlphanumeric")
                    <span></span>
                </label>
                <label for="Setting_PasswordComplexity_RequireUppercase" class="checkbox checkbox-outline">
                    <input id="Setting_PasswordComplexity_RequireUppercase" type="checkbox" name="RequireUppercase" value="true" @(Model.Settings.Security.PasswordComplexity.RequireUppercase ? "checked=\"checked\"" : "")>
                    @L("PasswordComplexity_RequireUppercase")
                    <span></span>
                </label>
            </div>
            <div class="form-group">
                <label for="RequiredLength">@L("PasswordComplexity_RequiredLength")</label>
                <input id="RequiredLength" type="number" name="RequiredLength" class="form-control" value="@Model.Settings.Security.PasswordComplexity.RequiredLength">
            </div>
        </form>
        <form class="p-5" id="DefaultPasswordComplexitySettingsForm" style="@(!Model.Settings.Security.UseDefaultPasswordComplexitySettings ? "display:none;" : "")">
            <div class="checkbox-list">
                <label for="Setting_DefaultPasswordComplexity_RequireDigit" class="checkbox checkbox-outline">
                    <input id="Setting_DefaultPasswordComplexity_RequireDigit" type="checkbox" name="RequireDigit" value="true" @(Model.Settings.Security.DefaultPasswordComplexity.RequireDigit ? "checked=\"checked\"" : "") disabled>
                    @L("PasswordComplexity_RequireDigit")
                    <span></span>
                </label>
                <label for="Setting_DefaultPasswordComplexity_RequireLowercase" class="checkbox checkbox-outline">
                    <input id="Setting_DefaultPasswordComplexity_RequireLowercase" type="checkbox" name="RequireLowercase" value="true" @(Model.Settings.Security.DefaultPasswordComplexity.RequireLowercase ? "checked=\"checked\"" : "") disabled>
                    @L("PasswordComplexity_RequireLowercase")
                    <span></span>
                </label>
                <label for="Setting_DefaultPasswordComplexity_RequireNonAlphanumeric" class="checkbox checkbox-outline">
                    <input id="Setting_DefaultPasswordComplexity_RequireNonAlphanumeric" type="checkbox" name="RequireNonAlphanumeric" value="true" @(Model.Settings.Security.DefaultPasswordComplexity.RequireNonAlphanumeric ? "checked=\"checked\"" : "") disabled>
                    @L("PasswordComplexity_RequireNonAlphanumeric")
                    <span></span>
                </label>
                <label for="Setting_DefaultPasswordComplexity_RequireUppercase" class="checkbox checkbox-outline">
                    <input id="Setting_DefaultPasswordComplexity_RequireUppercase" type="checkbox" name="RequireUppercase" value="true" @(Model.Settings.Security.DefaultPasswordComplexity.RequireUppercase ? "checked=\"checked\"" : "") disabled>
                    @L("PasswordComplexity_RequireUppercase")
                    <span></span>
                </label>
            </div>
            <div class="form-group mb-0">
                <label for="RequiredLength">@L("PasswordComplexity_RequiredLength")</label>
                <input id="RequiredLength" type="number" name="RequiredLength" class="form-control" value="@Model.Settings.Security.DefaultPasswordComplexity.RequiredLength" disabled>
            </div>
        </form>
    </div>

    <div>
        <h5>@L("UserLockOut")</h5>
        <form id="UserLockOutSettingsForm">
            <label for="Setting_UserLockOut_IsEnabled" class="checkbox checkbox-outline">
                <input id="Setting_UserLockOut_IsEnabled" type="checkbox" name="IsEnabled" value="true" @(Model.Settings.Security.UserLockOut.IsEnabled ? "checked=\"checked\"" : "")>
                @L("EnableUserAccountLockingOnFailedLoginAttemts")
                <span></span>
            </label>
            <div class="form-group">
                <label for="MaxFailedAccessAttemptsBeforeLockout">@L("MaxFailedAccessAttemptsBeforeLockout")</label>
                <input id="MaxFailedAccessAttemptsBeforeLockout" type="number" name="MaxFailedAccessAttemptsBeforeLockout" class="form-control" value="@Model.Settings.Security.UserLockOut.MaxFailedAccessAttemptsBeforeLockout">
            </div>
            <div class="form-group">
                <label for="DefaultAccountLockoutSeconds">@L("DefaultAccountLockoutDurationAsSeconds")</label>
                <input id="DefaultAccountLockoutSeconds" type="number" name="DefaultAccountLockoutSeconds" class="form-control" value="@Model.Settings.Security.UserLockOut.DefaultAccountLockoutSeconds">
            </div>
        </form>
    </div>

    @if (!ViewBag.IsMultiTenancyEnabled || Model.Settings.Security.TwoFactorLogin.IsEnabledForApplication)
    {
        <div>
            <h5>@L("TwoFactorLogin")</h5>
            <form id="TwoFactorLoginSettingsForm">
                <div class="checkbox-list">
                    <label for="Setting_TwoFactorLogin_IsEnabled" class="checkbox checkbox-outline">
                        <input id="Setting_TwoFactorLogin_IsEnabled" type="checkbox" name="IsEnabled" value="true" @(Model.Settings.Security.TwoFactorLogin.IsEnabled ? "checked=\"checked\"" : "")>
                        @L("EnableTwoFactorLogin")
                        <span></span>
                    </label>
                    @if (!ViewBag.IsMultiTenancyEnabled)
                    {
                        <label for="Setting_TwoFactorLogin_IsEmailProviderEnabled" class="checkbox checkbox-outline">
                            <input id="Setting_TwoFactorLogin_IsEmailProviderEnabled" type="checkbox" value="true" name="IsEmailProviderEnabled" @(Model.Settings.Security.TwoFactorLogin.IsEmailProviderEnabled ? "checked=\"checked\"" : "")>
                            @L("IsEmailVerificationEnabled")
                            <span></span>
                        </label>
                        <label for="Setting_TwoFactorLogin_IsSmsProviderEnabled" class="checkbox checkbox-outline">
                            <input id="Setting_TwoFactorLogin_IsSmsProviderEnabled" type="checkbox" value="true" name="IsSmsProviderEnabled" @(Model.Settings.Security.TwoFactorLogin.IsSmsProviderEnabled ? "checked=\"checked\"" : "")>
                            @L("IsSmsVerificationEnabled")
                            <span></span>
                        </label>
                        <label for="Setting_TwoFactorLogin_IsGoogleAuthenticatorEnabled" class="checkbox checkbox-outline">
                            <input id="Setting_TwoFactorLogin_IsGoogleAuthenticatorEnabled" type="checkbox" name="IsGoogleAuthenticatorEnabled" value="true" @(Model.Settings.Security.TwoFactorLogin.IsGoogleAuthenticatorEnabled ? "checked=\"checked\"" : "")>
                            @L("IsGoogleAuthenticatorEnabled")
                            <span></span>
                        </label>
                    }
                    <label for="Setting_TwoFactorLogin_IsRememberBrowserEnabled" class="checkbox checkbox-outline">
                        <input id="Setting_TwoFactorLogin_IsRememberBrowserEnabled" type="checkbox" value="true" name="IsRememberBrowserEnabled" @(Model.Settings.Security.TwoFactorLogin.IsRememberBrowserEnabled ? "checked=\"checked\"" : "")>
                        @L("AllowToRememberBrowserForTwoFactorLogin")
                        <span></span>
                    </label>
                </div>
            </form>
        </div>
    }
    @if (!ViewBag.IsMultiTenancyEnabled)
    {
        <div>
            <h5>@L("OneConcurrentLoginPerUser")</h5>
            <form id="OneConcurrentLoginPerUser">
                <div class="checkbox-list">
                    <label for="Setting_AllowOneConcurrentLoginPerUser" class="checkbox checkbox-outline">
                        <input id="Setting_AllowOneConcurrentLoginPerUser" type="checkbox" name="Setting_AllowOneConcurrentLoginPerUser" value="true" @(Model.Settings.Security.AllowOneConcurrentLoginPerUser ? "checked=\"checked\"" : "")>
                        @L("OneConcurrentLoginPerUserActive")
                        <span></span>
                    </label>
                </div>
            </form>
        </div>
    }
</div>

@if (!ViewBag.IsMultiTenancyEnabled || AbpZeroTemplateConsts.AllowTenantsToChangeEmailSettings)
{
    <div class="tab-pane" id="SettingsEmailSmtpTab">
        <form id="EmailSmtpSettingsForm">
            @if (ViewBag.IsMultiTenancyEnabled)
            {
                
            <div class="form-group">
                <label for="Settings_UseHostDefaultEmailSettings" class="checkbox checkbox-outline">
                    <input id="Settings_UseHostDefaultEmailSettings" type="checkbox" name="UseHostDefaultEmailSettings" value="true" @Html.Raw(Model.Settings.Email.UseHostDefaultEmailSettings ? "checked=\"checked\"" : "")>
                    @L("UseHostDefaultEmailSettings")
                    <span></span>
                </label>
            </div>
            }
            <div id="Settings_Email_Group" @Html.Raw(Model.Settings.Email.UseHostDefaultEmailSettings ? "style=\"display: none;\"" : "")>
                <div class="form-group">
                    <label for="DefaultFromAddress">@L("DefaultFromAddress")</label>
                    <input id="DefaultFromAddress" type="email" name="DefaultFromAddress" class="form-control" value="@Model.Settings.Email.DefaultFromAddress" maxlength="@Mes5GService.Authorization.Users.User.MaxEmailAddressLength">
                </div>

                <div class="form-group">
                    <label for="DefaultFromDisplayName">@L("DefaultFromDisplayName")</label>
                    <input id="DefaultFromDisplayName" type="text" name="DefaultFromDisplayName" class="form-control" value="@Model.Settings.Email.DefaultFromDisplayName" maxlength="128">
                </div>

                <div class="form-group">
                    <label for="SmtpHost">@L("SmtpHost")</label>
                    <input id="SmtpHost" type="text" name="SmtpHost" class="form-control" value="@Model.Settings.Email.SmtpHost" maxlength="64">
                </div>

                <div class="form-group">
                    <label for="SmtpPort">@L("SmtpPort")</label>
                    <input id="SmtpPort" type="number" name="SmtpPort" class="form-control" value="@Model.Settings.Email.SmtpPort" maxlength="5">
                </div>

                <div class="checkbox-list">
                    <label for="Settings_SmtpEnableSsl" class="checkbox checkbox-outline">
                        <input id="Settings_SmtpEnableSsl" type="checkbox" name="SmtpEnableSsl" value="true" @Html.Raw(Model.Settings.Email.SmtpEnableSsl ? "checked=\"checked\"" : "")>
                        @L("UseSsl")
                        <span></span>
                    </label>
                    <label for="Settings_SmtpUseDefaultCredentials" class="checkbox checkbox-outline">
                        <input id="Settings_SmtpUseDefaultCredentials" type="checkbox" name="SmtpUseDefaultCredentials" value="true" @Html.Raw(Model.Settings.Email.SmtpUseDefaultCredentials ? "checked=\"checked\"" : "")>
                        @L("UseDefaultCredentials")
                        <span></span>
                    </label>
                </div>

                <div class="form-group">
                    <label for="SmtpDomain">@L("DomainName")</label>
                    <input id="SmtpDomain" type="text" name="SmtpDomain" class="form-control" value="@Model.Settings.Email.SmtpDomain" maxlength="128">
                </div>

                <div class="form-group">
                    <label for="SmtpUserName">@L("UserName")</label>
                    <input id="SmtpUserName" type="text" name="SmtpUserName" class="form-control" value="@Model.Settings.Email.SmtpUserName" maxlength="128">
                </div>

                <div class="form-group">
                    <label for="SmtpPassword">@L("Password")</label>
                    <input id="SmtpPassword" type="password" name="SmtpPassword" class="form-control" value="@Model.Settings.Email.SmtpPassword" maxlength="128" autocomplete="new-password">
                </div>

                <h5>@L("TestEmailSettingsHeader")</h5>

                <div class="row">
                    <div class="form-group col-md-4">
                        <input id="TestEmailAddressInput" type="text" class="form-control input-sm" value="@ViewBag.CurrentUserEmail">
                    </div>
                    <div class="form-group col-md-2">
                        <button id="SendTestEmailButton" class="btn btn-success" type="button">@L("SendTestEmail")</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
}

@if (ViewBag.IsMultiTenancyEnabled)
{
    <div class="tab-pane" id="BillingTab">
        <form id="BillingSettingsForm" class="form">
            <h5>@L("InvoiceInformation")</h5>
            <div class="form-group">
                <label for="LegalName">@L("LegalName")</label>
                <input id="LegalName" type="text" class="form-control" name="LegalName" value="@Model.Settings.Billing.LegalName" maxlength="64">
            </div>

            <div class="form-group">
                <label for="Address">@L("Address")</label>
                <textarea id="Address" rows="5" class="form-control" name="Address" class="form-control" maxlength="256">@Model.Settings.Billing.Address</textarea>
            </div>

            <div class="form-group">
                <label for="TaxVatNo">@L("Tax/VatNo")</label>
                <input id="TaxVatNo" type="text" class="form-control" name="TaxVatNo" value="@Model.Settings.Billing.TaxVatNo" maxlength="32">
            </div>
        </form>
    </div>
}

@if (!ViewBag.IsMultiTenancyEnabled)
{
    <div class="tab-pane" id="OtherSettingsTab">
        <form id="OtherSettingsForm" class="form">
            <div class="checkbox-list">
                <h5>@L("QuickThemeSelection")</h5>
                <label for="Setting_IsQuickThemeSelectEnabled" class="checkbox checkbox-outline">
                    <input id="Setting_IsQuickThemeSelectEnabled" type="checkbox" name="IsQuickThemeSelectEnabled" value="true" @(Model.Settings.UserManagement.IsQuickThemeSelectEnabled ? "checked=\"checked\"" : "")>
                    @L("IsQuickThemeSelectEnabled")
                    <span></span>
                </label>
            </div>
        </form>
    </div>
}

@if (Model.EnabledSocialLoginSettings.Any())
{
    <div class="tab-pane" id="ExternalLoginSettingsTab">
    @if (Model.EnabledSocialLoginSettings.Contains("Facebook"))
    {
        <form id="ExternalLoginFacebookSettingsForm" class="form">
            <div class="accordion">
                <h5>Facebook</h5>
                <label for="Setting_Facebook_UseHostSettings" class="checkbox checkbox-outline">
                    <input id="Setting_Facebook_UseHostSettings" type="checkbox" name="Google_UseHostSettings" value="true"
                           @(string.IsNullOrWhiteSpace(Model.Settings.ExternalLoginProviderSettings.Facebook.AppId) ? "checked=\"checked\"" : "")>
                    @L("UseHostSettings")
                    <span></span>
                </label>
                <div class="collapse @(string.IsNullOrWhiteSpace(Model.Settings.ExternalLoginProviderSettings.Facebook.AppId) ? "" : "show")">
                    <div class="form-group">
                        <label for="Setting_Facebook_AppId">@L("AppId")*</label>
                        <input id="Setting_Facebook_AppId" type="text" class="form-control" name="AppId" value="@Model.Settings.ExternalLoginProviderSettings.Facebook.AppId">
                    </div>
                    <div class="form-group">
                        <label for="Setting_Facebook_AppSecret">@L("AppSecret")*</label>
                        <div class="input-group">
                            <input id="Setting_Facebook_AppSecret" type="password" class="form-control" name="AppSecret" value="@Model.Settings.ExternalLoginProviderSettings.Facebook.AppSecret">
                            <div class="input-group-append">
                                <button class="btn btn-primary passwordShowButton" type="button" data-id="Setting_Facebook_AppSecret">
                                    <i class="far fa-eye text-white"></i> <span> @L("Show")</span>
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    }

    @if (Model.EnabledSocialLoginSettings.Contains("Google"))
    {
        <hr>
        <form id="ExternalLoginGoogleSettingsForm" class="form">
            <div class="accordion">
                <h5>Google</h5>
                <label for="Setting_Google_UseHostSettings" class="checkbox checkbox-outline">
                    <input id="Setting_Google_UseHostSettings" type="checkbox" name="Google_UseHostSettings" value="true"
                           @(string.IsNullOrWhiteSpace(Model.Settings.ExternalLoginProviderSettings.Google.ClientId) ? "checked=\"checked\"" : "")>
                    @L("UseHostSettings")
                    <span></span>
                </label>
                <div class="collapse @(string.IsNullOrWhiteSpace(Model.Settings.ExternalLoginProviderSettings.Google.ClientId) ? "" : "show")">
                    <div class="form-group">
                        <label for="Setting_Google_ClientId">@L("ClientId")*</label>
                        <input id="Setting_Google_ClientId" type="text" class="form-control" name="ClientId" value="@Model.Settings.ExternalLoginProviderSettings.Google.ClientId">
                    </div>
                    <div class="form-group">
                        <label for="Setting_Google_ClientSecret">@L("ClientSecret")*</label>
                        <div class="input-group">
                            <input id="Setting_Google_ClientSecret" type="password" class="form-control" name="ClientSecret" value="@Model.Settings.ExternalLoginProviderSettings.Google.ClientSecret">
                            <div class="input-group-append">
                                <button class="btn btn-primary passwordShowButton" type="button" data-id="Setting_Google_ClientSecret">
                                    <i class="far fa-eye text-white"></i> <span> @L("Show")</span>
                                </button>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="Setting_Google_UserInfoEndpoint">@L("UserInfoEndpoint")</label>
                        <input id="Setting_Google_UserInfoEndpoint" type="text" class="form-control" name="UserInfoEndpoint" value="@Model.Settings.ExternalLoginProviderSettings.Google.UserInfoEndpoint">
                    </div>
                </div>
            </div>
        </form>
    }

    @if (Model.EnabledSocialLoginSettings.Contains("Twitter"))
    {
        <hr>
        <form id="ExternalLoginTwitterSettingsForm" class="form">
            <div class="accordion">
                <h5>Twitter</h5>
                <label for="Setting_Twitter_UseHostSettings" class="checkbox checkbox-outline">
                    <input id="Setting_Twitter_UseHostSettings" type="checkbox" name="Twitter_UseHostSettings" value="true"
                           @(string.IsNullOrWhiteSpace(Model.Settings.ExternalLoginProviderSettings.Twitter.ConsumerKey) ? "checked=\"checked\"" : "")>
                    @L("UseHostSettings")
                    <span></span>
                </label>
                <div class="collapse @(string.IsNullOrWhiteSpace(Model.Settings.ExternalLoginProviderSettings.Twitter.ConsumerKey) ? "" : "show")">
                    <div class="form-group">
                        <label for="Setting_Twitter_ConsumerKey">@L("ConsumerKey")*</label>
                        <input id="Setting_Twitter_ConsumerKey" type="text" class="form-control" name="ConsumerKey" value="@Model.Settings.ExternalLoginProviderSettings.Twitter.ConsumerKey">
                    </div>
                    <div class="form-group">
                        <label for="Setting_Twitter_ConsumerSecret">@L("ConsumerSecret")*</label>
                        <div class="input-group">
                            <input id="Setting_Twitter_ConsumerSecret" type="password" class="form-control" name="ConsumerSecret" value="@Model.Settings.ExternalLoginProviderSettings.Twitter.ConsumerSecret">
                            <div class="input-group-append">
                                <button class="btn btn-primary passwordShowButton" type="button" data-id="Setting_Twitter_ConsumerSecret">
                                    <i class="far fa-eye text-white"></i> <span> @L("Show")</span>
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    }

    @if (Model.EnabledSocialLoginSettings.Contains("Microsoft"))
    {
        <hr>
        <form id="ExternalLoginMicrosoftSettingsForm" class="form">
            <div class="accordion">
                <h5>Microsoft</h5>
                <label for="Setting_Microsoft_UseHostSettings" class="checkbox checkbox-outline">
                    <input id="Setting_Microsoft_UseHostSettings" type="checkbox" name="Microsoft_UseHostSettings" value="true"
                           @(string.IsNullOrWhiteSpace(Model.Settings.ExternalLoginProviderSettings.Microsoft.ClientId) ? "checked=\"checked\"" : "")>
                    @L("UseHostSettings")
                    <span></span>
                </label>
                <div class="collapse @(string.IsNullOrWhiteSpace(Model.Settings.ExternalLoginProviderSettings.Microsoft.ClientId) ? "" : "show")">
                    <div class="form-group">
                        <label for="Setting_Microsoft_ClientId">@L("ClientId")*</label>
                        <input id="Setting_Microsoft_ClientId" type="text" class="form-control" name="ClientId" value="@Model.Settings.ExternalLoginProviderSettings.Microsoft.ClientId">
                    </div>
                    <div class="form-group">
                        <label for="Setting_Microsoft_ClientSecret">@L("ClientSecret")*</label>
                        <div class="input-group">
                            <input id="Setting_Microsoft_ClientSecret" type="password" class="form-control" name="ClientSecret" value="@Model.Settings.ExternalLoginProviderSettings.Microsoft.ClientSecret">
                            <div class="input-group-append">
                                <button class="btn btn-primary passwordShowButton" type="button" data-id="Setting_Microsoft_ClientSecret">
                                    <i class="far fa-eye text-white"></i> <span> @L("Show")</span>
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    }
    @if (Model.EnabledSocialLoginSettings.Contains("OpenId"))
    {
        <hr>
        <form id="ExternalLoginOpenIdConnectSettingsForm" class="form">
            <div class="accordion">
                <h5>OpenID Connect</h5>
                <label for="Setting_OpenIdConnect_UseHostSettings" class="checkbox checkbox-outline">
                    <input id="Setting_OpenIdConnect_UseHostSettings" type="checkbox" name="OpenIdConnect_UseHostSettings" value="true"
                           @(string.IsNullOrWhiteSpace(Model.Settings.ExternalLoginProviderSettings.OpenIdConnect.ClientId) ? "checked=\"checked\"" : "")>
                    @L("UseHostSettings")
                    <span></span>
                </label>

                <div class="collapse @(string.IsNullOrWhiteSpace(Model.Settings.ExternalLoginProviderSettings.OpenIdConnect.ClientId) ? "" : "show")">
                    <div class="form-group">
                        <label for="Setting_OpenIdConnect_ClientId">@L("ClientId")*</label>
                        <input id="Setting_OpenIdConnect_ClientId" type="text" class="form-control" name="ClientId" value="@Model.Settings.ExternalLoginProviderSettings.OpenIdConnect.ClientId">
                    </div>
                    <div class="form-group">
                        <label for="Setting_OpenIdConnect_ClientSecret">@L("ClientSecret")</label>
                        <div class="input-group">
                            <input id="Setting_OpenIdConnect_ClientSecret" type="password" class="form-control" name="ClientSecret" value="@Model.Settings.ExternalLoginProviderSettings.OpenIdConnect.ClientSecret">
                            <div class="input-group-append">
                                <button class="btn btn-primary passwordShowButton" type="button" data-id="Setting_OpenIdConnect_ClientSecret">
                                    <i class="far fa-eye text-white"></i> <span> @L("Show")</span>
                                </button>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="Setting_OpenIdConnect_Authority">@L("Authority")*</label>
                        <input id="Setting_OpenIdConnect_Authority" type="text" class="form-control" name="Authority" value="@Model.Settings.ExternalLoginProviderSettings.OpenIdConnect.Authority">
                    </div>

                    <label for="Setting_OpenIdConnect_ValidateIssuer" class="checkbox checkbox-outline">
                        <input id="Setting_OpenIdConnect_ValidateIssuer" type="checkbox" name="OpenIdConnect_ValidateIssuer" value="true"
                               @(Model.Settings.ExternalLoginProviderSettings.OpenIdConnect.ValidateIssuer ? "checked=\"checked\"" : "")>
                        @L("ValidateIssuer")
                        <span></span>
                    </label>

                    <div class="form-group col-12">
                        <label>
                            @L("ClaimsMapping") <small>(@L("OpenIdClaimsCleanListToRevertToDefaultClaimsMessage"))</small>
                        </label>
                        <div id="claimsMappingsContainer"></div>
                    </div>
                </div>
            </div>
        </form>
    }
    @if (Model.EnabledSocialLoginSettings.Contains("WsFederation"))
    {
        <hr>
        <form id="ExternalLoginWsFederationSettingsForm" class="form">
            <div class="accordion">
                <h5>WsFederation</h5>
                <label for="Setting_WsFederation_UseHostSettings" class="checkbox checkbox-outline">
                    <input id="Setting_WsFederation_UseHostSettings" type="checkbox" name="WsFederation_UseHostSettings" value="true"
                           @(string.IsNullOrWhiteSpace(Model.Settings.ExternalLoginProviderSettings.WsFederation.ClientId) ? "checked=\"checked\"" : "")>
                    @L("UseHostSettings")
                    <span></span>
                </label>

                <div class="collapse @(string.IsNullOrWhiteSpace(Model.Settings.ExternalLoginProviderSettings.WsFederation.ClientId) ? "" : "show")">
                    <div class="form-group">
                        <label for="Setting_WsFederation_ClientId">@L("ClientId")</label>
                        <input id="Setting_WsFederation_ClientId" type="text" class="form-control" name="ClientId" value="@Model.Settings.ExternalLoginProviderSettings.WsFederation.ClientId">
                    </div>
                    <div class="form-group">
                        <label for="Setting_WsFederation_Tenant">@L("Tenant")</label>
                        <input id="Setting_WsFederation_Tenant" type="text" class="form-control" name="Tenant" value="@Model.Settings.ExternalLoginProviderSettings.WsFederation.Tenant">
                    </div>
                    <div class="form-group">
                        <label for="Setting_WsFederation_MetaDataAddress">@L("MetaDataAddress")</label>
                        <input id="Setting_WsFederation_MetaDataAddress" type="text" class="form-control" name="MetaDataAddress" value="@Model.Settings.ExternalLoginProviderSettings.WsFederation.MetaDataAddress">
                    </div>
                    <div class="form-group">
                        <label for="Setting_WsFederation_Wtrealm">@L("Wtrealm")</label>
                        <input id="Setting_WsFederation_Wtrealm" type="text" class="form-control" name="Wtrealm" value="@Model.Settings.ExternalLoginProviderSettings.WsFederation.Wtrealm">
                    </div>
                    <div class="form-group">
                        <label for="Setting_WsFederation_Authority">@L("Authority")</label>
                        <input id="Setting_WsFederation_Authority" type="text" class="form-control" name="Authority" value="@Model.Settings.ExternalLoginProviderSettings.WsFederation.Authority">
                    </div>

                    <div class="form-group col-12">
                        <label>
                            @L("ClaimsMapping") <small>(@L("OpenIdClaimsCleanListToRevertToDefaultClaimsMessage"))</small>
                        </label>
                        <div id="Setting_WsFederation_ClaimsMappingsContainer"></div>
                    </div>
                </div>
            </div>
        </form>
    }

    </div>
}
</div>
</div>
</div>
</div>
</div>
</div>
